/**
 * 
 */
package test.org.cnbi.task;

/**
 * Copyright © 2014中国经邦. All rights reserved.
 * @author 龚佳新
 * @date 2014年4月15日上午9:12:18
 * @cnbi-web
 */
import org.springframework.core.task.TaskExecutor;

public class TaskExecutorExample {

	private TaskExecutor taskExecutor;

	public TaskExecutorExample(TaskExecutor taskExecutor) {
		this.taskExecutor = taskExecutor;
	}
   /**
    * 内部类
    * Copyright © 2014中国经邦. All rights reserved.
    * @author 龚佳新
    * @date 2014年4月15日上午9:13:27
    * @cnbi-web
    */
	private class MessagePrinterTask implements Runnable {

		private String message;

		public MessagePrinterTask(String message) {
			this.message = message;
		}

		public void run() {
			System.out.println(message);
		}

	}

	public void printMessages() {
		for (int i = 0; i < 25; i++) {
			taskExecutor.execute(new MessagePrinterTask("Message" + i));
		}
	}
}
